<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>短信项目模板配置</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet"
	type="text/css">
<link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<script src="../../layui/layui.js"></script>
<script src="../../js/jquery-1.8.3.js"></script>
<script src="../../js/util.js"></script>
<script src="../../js/jquery-ui-1.10.4.custom.min.js"></script>

<script>
	layui.use([ 'form', 'jquery', 'element', 'laydate', 'layer', 'upload' ], function() {
		var form = layui.form;
		var $ = layui.$;
		var laydate = layui.laydate;
		var layer = layui.layer;
		var upload = layui.upload;
		var step = 1;//用于下一步操作展示隐藏div
		var flagMgr;//判断项目名是否重复
		var copyMgrId="";//被复制项目的Id
		var flagCity;//判断地市是否欠费
		var dutyFlag=0;//获取登录者权限
		var mgrId="";//新增的项目编码
		var sessionCityId = "";
		var mgrNameId;//项目简称id
		var everyDayStartTimeFlag = '00:00:00';
		var everyDayEndTimeFlag = '24:00:00';
		laydate.render({
	             elem: '#startTime'
	             , type: 'datetime'
	             ,min:minDate()
	        });
	    laydate.render({
	             elem: '#endTime'
	             , type: 'datetime'
	             ,min:minDate(),
	              done: function (value,endDate) {//修改默认时间为23：59：59
                    var hours = endDate.hours;
                    var minutes = endDate.minutes;
                    var seconds = endDate.seconds;
                    if (hours == "0" && minutes == "0" && seconds == "0"){
                        $(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click();
                        // 如果是datetime的范围选择，改变开始时间默认值
                        $(".laydate-main-list-0 .layui-laydate-content li ol li:last-child").click();
                        // 改变结束时间默认值
                        $(".laydate-main-list-1 .layui-laydate-content li ol li:last-child").click();
                        // 如果不是范围选择，只是日期时间选择
                        $(".laydate-main-list-0 .layui-laydate-content li ol li:last-child").click();                       
                        $(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click();
                    }                   
                }
	        });    
	        
	    laydate.render({
                elem: '#everyDayStartTime'
                , type: 'time'
                , value: '08:00:00'
                , btns: ['clear', 'confirm']
            });
            laydate.render({
                elem: '#everyDayEndTime'
                , type: 'time'
                , value: '20:00:00'
                , btns: ['clear', 'confirm']
            });    
		laydate.render({
			elem : '#thresholdStartTime'
		});
		laydate.render({
			elem : '#thresholdEndTime'
		});

	    function minDate(){
			    var now = new Date();
			    return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
		}
		
		function everyDayStartTime(){
			    var now = new Date();
			    if(dutyFlag==0 || dutyFlag==1){
			    	return "00:00:00";
			    }else{
			    	return "08:00:00";
			    }
		}
		
		function everyDayEndTime(){
			    var now = new Date();
			    if(dutyFlag==0 || dutyFlag==1){
			    	return "24:00:00";
			    }else{
			    	return "20:00:00";
			    }
		}

		$('#upload2').on('click', function () {
				var choose = $("span.layui-upload-choose").text();
				console.info(choose);
				if(choose!=null && choose!=''){
					layer.confirm('确认模板信息无误吗？是否需要再次查看', {
						btn : [ '不需要', '需要' ] //按钮
					}, function() {
						console.info("-----2222---");
						$('#uploadFile').trigger("click");
					});
				}else{
					fileUpload();
				}
		});
		upload.render({
					elem : '#import',
					url : '/template2/modifyByImport',
					auto : false, //关闭自动上传
					accept : 'file', //普通文件
					exts : 'csv', //只允许上传csv文件 //,multiple: true
					bindAction : '#uploadFile',
					before : function() {
						var cityId=$("#cityId").val();
						var mgrType=$("#mgrType").val();
						var startTime=$("#startTime").val();
				        var endTime=$("#endTime").val();
				        var everyDayStartTime=$("#everyDayStartTime").val();
				        var everyDayEndTime=$("#everyDayEndTime").val();
				        var realTime=$("input[name='realTime']:checked").val();
				        var isLocal=$("input[name='isLocal']:checked").val();
				        var isThreshold = 0;
				        //var isCz=$("input[name='isCz']:checked").val();
				        
				        var localIsCz=$("input[name='localIsCz']:checked").val();
	        			var nonLocalIsCz=$("input[name='nonLocalIsCz']:checked").val();
				        
			            $("input:checkbox[name='isThreshold']:checked").each(function () {
			                isThreshold += parseInt($(this).val());
			            });
			            var threshold = $("#threshold").val();
			            var cycleThreshold=0;
			            var cycle;
			            if(isThreshold==2||isThreshold==3){
			               	//cycle=$("#cycle").val();
			               	cycle = $("input[name='cycle']:checked").val();
			                cycleThreshold=$("#cycleThreshold").val();
			            }
			            var content=$("#content").val();
			            var localDate = 7;
			            var isProvince = 0;
			            var nonlocalDate = 7;
			            if(isLocal==1){
			            	isProvince=$("input[name='province']:checked").val();
			            	nonlocalDate=$("input[name='nonlocalDate']:checked").val();
			            }else if(isLocal==2){
			            	//isProvince=1;
			            	isProvince=$("input[name='province']:checked").val();
			            	localDate=$("input[name='localDate']:checked").val();
			            	nonlocalDate=$("input[name='nonlocalDate']:checked").val();
			            }else if(isLocal==0){
			             	localDate=$("input[name='localDate']:checked").val();
			            }
			            var param = {
			            		mgrId: mgrId,
			            		mgrType: mgrType,
			                    startTime: startTime,
			                    endTime: endTime,   
			                    everyDayStartTime: everyDayStartTime,
			                    everyDayEndTime: everyDayEndTime,
			                    realTime: realTime,
			                    isLocal: isLocal,
                    			localIsCz: localIsCz,
                    			nonLocalIsCz: nonLocalIsCz,			                    
			                    isThreshold:isThreshold,
			                    threshold:threshold,
			                    cycleThreshold:cycleThreshold,
			                    cycle:cycle,
			                    newContent:content,
			                    localDate: localDate,
			                    nonlocalDate: nonlocalDate,
			                    isProvince: isProvince,
			                    effectTime:startTime,
			                    reset:"0",
			                    flag: "modify",
			                    cityId: cityId,
			                    importType:'importCover'
			                };
							var json = JSON.stringify(param);
							console.info("----"+json);
			                //var json = JSON.stringify(param);
			                	if (isNull(mgrType)) {
						          layer.msg("项目类型不能为空");
						          return false;
						        }
								if (isNull(startTime)) {
						          layer.msg("发送开始时间不能为空");
						          return false;
						        }
						        if (isNull(everyDayStartTime)) {
						          layer.msg("每日发送开始时间不能为空");
						          return false;
						        }
						        if (isNull(everyDayEndTime)) {
						          layer.msg("每日发送结束时间不能为空");
						          return false;
						        }
						        if (isNull(realTime)) {
						          layer.msg("发送实时性不能为空");
						          return false;
						        }
						        if (isNull(isLocal)) {
						          layer.msg("号码发送范围不能为空");
						          return false;
						        }
						        if (isNull(content)) {
						          layer.msg("短信内容不能为空");
						          return false;
						        }
						        if (""!=endTime && null!=endTime && startTime>=endTime) {
					              layer.msg("发送结束时间不能小于等于开始时间");
					              return false;
					            }
					            if (everyDayStartTime>=everyDayEndTime) {
					              layer.msg("每日发送结束时间不能小于等于每日开始时间");
					              return false;
					            }
						layer.load(); //上传loading
						this.data = param;
					},done : function(obj) {
						console.info(obj);
						layer.closeAll('loading'); //关闭loading
						if (obj.code == 0 && obj.data!=null) {
							var data = obj.data;
							var num = data.toString().split(",");
							layer.confirm('模板添加成功，并成功导入' + data[0] + '个区域,' + data[1] + '个基站', {
								btn: ['确定'] //按钮
							}, function () {
								location.href="smsTemplateManage2.html";
							});
						}
						else{
			               layer.confirm(obj.msg, {
								btn: ['确定'] //按钮
							}, function () {
								layer.close(layer.index);
								//location.href="smsTemplateManage2.html";
							});
			            }		
					},
					error : function(index, upload) {
						layer.closeAll('loading'); //关闭loading
						layer.msg("上传过程中出现异常，请重试");
					}
				});
		
		


		function submit(parm) {
			layer.confirm('确认模板信息无误吗？是否需要再次查看', {
				btn : [ '不需要', '需要' ] //按钮
			}, function() {
				$.ajax({
					type : 'post',
					data : parm,
					url : "/template2/configure",
					beforeSend : function() {
						loading = layer.load(0, {
							shade : false
						});
					},
					success : function(json) {
						console.info(json);
						layer.close(loading);
						if (json.code == 0) {
							mgrId = json.data;
						} else {
							layer.msg(json.msg);
						}
					},
					complete : function() {},
					error : function(data) {
						layer.msg('系统异常，请联系管理员处理!');
					}
				});
			});
			return mgrId;
		}
		
		form.on('radio(localDate)', function(data) {
			layer.open({
              content: '号码保存时间将被更改为 '+$("input[name='localDate']:checked").val()+" 天"
              ,btn: ['确定']
            });			
		});
		
		form.on('radio(nonlocalDate)', function(data) {
			layer.open({
              content: '号码保存时间将被更改为 '+$("input[name='nonlocalDate']:checked").val()+" 天"
              ,btn: ['确定']
            });			
		});

		form.on('radio(localDate1)', function(data) {
			if (data.value == 0) {
				$("#province").hide();
				$("#local").show();
				$("#nonlocal").hide();
 				$("#nonLocalIsCz").hide();
/* 				$("#localIsCz").show();  */
				
			} else if(data.value == 1){
				$("#local").hide();
				$("#nonlocal").show();
				$("#province").show();
/* 				$("#localIsCz").hide();*/
				$("#nonLocalIsCz").show(); 
				
				
			} else if(data.value == 2){
				$("#nonlocal").show();
				$("#local").show();
				$("#province").show();
/* 				$("#localIsCz").show();*/
				$("#nonLocalIsCz").show(); 
			}
		});

		//根据城市ID查询扩展码
		function selectExtInfo(cityId) {
			var data;
			var url = '/util/findExdId?cityId=' + cityId;
			$.ajax({
				type : 'post',
				async : false,
				url : url,
				success : function(json) {
					console.log(json.data);
					data = json.data;
				},
				error : function() {
					layer.msg('系统异常，请联系管理员处理!');
				}
			}
			);
			return data;
		}
		//动态拼接扩展码
		function appendExtId(data) {
			if (data.length != null) {
				var options = '<option value="">请选择</option>';
				for (var i = 0; i < data.length; i++) {
					options += '<option value="' + data[i] + '">' + data[i] + '</option>';
				}
				$('#extId').html(options);
			} else {
			}
			form.render();
		}
		//监听短信内容
		$('textarea').bind('input propertychange', function(){  
			var contentLength = $("#content").val().length;
			$("#contentSize").html(contentLength);
			$("#contentShortNum").html(Math.ceil(contentLength/70));
	    });  
		//监听第三步中的地市、区县、项目
		//监听区县
            form.on('select(cityId_third)', function (data) {
                var data2 = selectCountyId(data.value);
                appendCountyThird(data2);
                var data1 = selectMgrInfo(data.value);
                appendMgrThird(data1);
            });
			
			 //监听项目
            form.on('select(countyId_third)', function (data) {
	            	if(data.value==null||data.value==''){
	            		var cityId = $("#cityId_third").val();
	            		var data1 = selectMgrInfo(cityId);
	            		appendMgrThird(data1);
	            	}else{
	            		var data1 = selectMgrInfo(data.value);
	                	appendMgrThird(data1);
	            	}
            });
            //动态拼接区县
            function appendCountyThird(data){
                if (data.length != null) {
                    var options = '<option value="">请先选择地市</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].countyId + '">' + data[i].countyName + '</option>';
                    }
                    $('#countyId_third').html(options);
                } else {
                    $('#countyId_third').html('该地市下没有区县');
                }
                form.render();
            }
            
            //拼接项目类型
            function appendMgrType(data){
            	if(data.length !=null){
            		var options= '<option value="">请选择</option>';
            		for(var i=0 ; i<data.length ; i++){
            			options += '<option value="' + data[i].typeId + '">' + data[i].typeName + '</option>';
            			$('#mgrType').html(options);
            		}
            	}else{
            		$('#mgrType').html('暂无项目类型');
            	}
            	form.render();
            	
            }
			
			 //动态拼接项目
            function appendMgrThird(data) {
                if (data.length != null) {
                    var options = '<option value="">请选择</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
                    }
                    $('#mgrId_third').html(options);
                } else {
                    $('#mgrId_third').html('<option value="">该区县下没有项目</option>');
                }
                form.render();
            }
        //监听第三步中的地市、区县、项目 end
		//监听区县
            form.on('select(cityId)', function (data) {
                var data2 = selectCountyId(data.value);
                appendCounty(data2);
				var data = selectMgrGroupList(data.value,"");
				appendMgrGroup(data);
            });

		//监听区县
		form.on('select(countyId)', function (data) {
			var data = selectMgrGroupList($("#cityId").val(),data.value);
			appendMgrGroup(data);
		});
			
			//动态拼接区县
            function appendCounty(data){
                if (data.length != null) {
                    var options = '<option value="">请先选择地市</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].countyId + '">' + data[i].countyName + '</option>';
                    }
                    $('#countyId').html(options);
                } else {
                    $('#countyId').html('该地市下没有区县');
                }
                form.render();
            }
			
			 //动态拼接项目
            function appendMgr(data) {
                if (data.length != null) {
                    var options = '<option value="">请选择</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
                    }
                    $('#mgrId').html(options);
                } else {
                    $('#mgrId').html('<option value="">该区县下没有项目</option>');
                }
                form.render();
            }
            
            function selectMgrType(){
            	var data;
            	var url='/util/findMgrType';
            	$.ajax({
            		type : 'post',
            		async : false,
            		url : url,
            		success:function(json){
            			data=json.data;
            		},error: function(){
            			layer.msg('系统异常，请联系管理员处理！');
            		}            	
            	});
            	return data;
            }
			
			//根据城市ID查询区县
            function selectCountyId(cityId) {
                var data;
                var url = '/util/findCountyByCityId?cityId=' + cityId;
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            data = json.data;
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }
			
			//根据城市ID和区县查询项目
            function selectMgrInfo(countyId) {
                var data;
                var url = '/util/findByMgrId?countyId=' + countyId;
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            data = json.data;
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }

		//查询项目分组信息
		function selectMgrGroupList(cityId,countyId) {
			var data;
			if(cityId == 25 || cityId == null){
				cityId = "";
			}
			if(countyId == null){
				countyId = "";
			}
			var url = '/smsMgrGroup/qryGroupList2?cityId=' + cityId+'&countyId='+countyId;
			$.ajax({
						type: 'post',
						async: false,
						url: url,
						success: function (json) {
							data = json.data;
						}, error: function () {
							layer.msg('系统异常，请联系管理员处理!');
						}
					}
			);
			return data;
		}
		//动态拼接项目分组
		function appendMgrGroup(data){
			if(data!=null){
				if (data.length != null) {
					var options = '<option value="">暂不关联分组</option>';
					for (var i = 0; i < data.length; i++) {
						options += '<option value="' + data[i].groupId + '">' + data[i].groupName + '</option>';
					}
					$('#mgrGroup').html(options);
				} else {
					$('#mgrGroup').html('该地市或区县暂无项目分组');
				}
			}

			form.render();
		}
		
		//判断项目名称是否重复
			function judgeMgrName(mgrName){
				var url = '/util/getMgrName';
			    $.ajax({
			            url: url,
			            type: 'post',
			            async: false,
			            data: "mgrName="+mgrName,
			            success: function (json) {
			                flagMgr = json.data;
			            }, error: function () {
			                layer.msg('系统异常，请联系管理员处理!');
			            }
			        }
			    );
		}
		//判断地市是否欠费
		function judgeCity(cityId) {
			var url2 = '/citySign/find';
			var param2 = {
				cityId : cityId,
				page : 1,
				limit : 1
			};
			$.ajax({
				type : 'post',
				data : param2,
				url : url2,
				async : false,
				success : function(obj2) {
					flagCity = obj2.data[0].signId;
				},
				error : function() {
					layer.msg('系统异常，请联系管理员处理!');
				}
			});
		}

		//获取复制的项目ID
		$('#copy').on('click',function(){
		 	copyMgrId = $("#mgrId_third").val();
		 	mgrNameId = $("#mgrName1").val();
			 	if((''!=mgrNameId && null!=mgrNameId)&&(''!=copyMgrId && null!=copyMgrId))
			 	{layer.confirm('项目名称与项目简称只需选择一个', {
						btn: ['确定'] //按钮
					});}else{		 	
			 	if((''!=mgrNameId && null!=mgrNameId)){			
    					var url = '/util/findMgrByName';
    					var param = {
    						mgrName : mgrNameId
    					};
    					$.ajax({
    						type : 'post',
    						async : false,
    						url : url,
    						data : param,
    						success : function(json) {
    							 data = json.data; 
    							 console.log(data.id);	  						
    						 mgrNameId=data.id;	    		
    						},
    						error : function() {
    							layer.msg('系统异常，请联系管理员处理!');
    						}
    					});
    					copyMgrId=mgrNameId;  
    					console.log(copyMgrId); 					
			 	}
			 	layer.confirm('已复制对应基站', {
						btn: ['确定'] //按钮
					});
			 	}		 	
		 });
		
		 $('#next').on('click', function () {

		 	if(step==1) {
					submitFisrt();
		 	}else if(step==2){
		 		submitSecond();
		 	}
		 });

		//查看短信条数

		$('#qryContentCount').on('click', function() {
			$('#contentCount').show();
			var param;
			var content = $("#content").val();
			var url;
			var isThreshold=0;
			$("input:checkbox[name='isThreshold']:checked").each(function() {
				isThreshold += parseInt($(this).val());
			});
			var threshold = $("#threshold").val();
			var cycleThreshold = 0;
			var cycle;
			if (isThreshold == 2 || isThreshold == 3) {
				cycle = $("input[name='cycle']:checked").val();
				cycleThreshold = $("#cycleThreshold").val();
			}

			if(isNull(content)){
            		layer.msg("短信内容为空！");
            		return false;
            	}else{
            		url="/util/contentCount";
            		param={
            			content : content
            		};
            		
            		$.ajax({
            			type: 'post',
	                    data: param,
	                    url: url,
            			 beforeSend: function () {
	                        loading = layer.load(0, {shade: false});
	                    },
	                    success: function (json) {
	                        layer.close(loading);
	                        if (json.code == 0) {
	                        	$("#contentLength").html(content.length);
	                            $("#contentNum").html(json.data);
	                            if(isThreshold==1){
	                            	$("#thresholdNum").html(" , 总计将发送："+(json.data)*threshold+"  条");
	                            }else if(isThreshold==2 &&cycle==1){
	                            	$("#thresholdNum").html(" , 每年将发送："+(json.data)*cycleThreshold+"  条");
	                            }else if(isThreshold==2 &&cycle==2){
	                            	$("#thresholdNum").html(" , 每月将发送："+(json.data)*cycleThreshold+"  条");
	                            }else if(isThreshold==2 &&cycle==3){
	                            	$("#thresholdNum").html(" , 每周将发送："+(json.data)*cycleThreshold+"  条");
	                            }else if(isThreshold==2 &&cycle==4){
	                            	$("#thresholdNum").html(" , 每天将发送："+(json.data)*cycleThreshold+"  条");
	                            }else if(isThreshold==3 &&cycle==1){
	                            	$("#thresholdNum").html(" , 总计将发送："+(json.data)*threshold+"  条 , 每年将发送："+(json.data)*cycleThreshold+"  条");
	                            }else if(isThreshold==3 &&cycle==2){
	                            	$("#thresholdNum").html(" , 总计将发送："+(json.data)*threshold+"  条 , 每月将发送："+(json.data)*cycleThreshold+"  条");
	                            }else if(isThreshold==3 &&cycle==3){
	                            	$("#thresholdNum").html(" , 总计将发送："+(json.data)*threshold+"  条 , 每周将发送："+(json.data)*cycleThreshold+"  条");
	                            }else if(isThreshold==3 &&cycle==4){
	                            	$("#thresholdNum").html(" , 总计将发送："+(json.data)*threshold+"  条 , 每天将发送："+(json.data)*cycleThreshold+"  条");
	                            }	                           	                            
	                        } else {
	                            layer.msg(json.msg);
	                        }
	                    }
            		});
            		
            		$('#contentCount').show();
            	}
            });
            
		function submitFisrt(){
			var cityId=$("#cityId").val();
			sessionCityId = cityId;
			judgeCity(cityId);
			var countyId=$("#countyId").val();
			var name = $("#name").val();
			var mgrType = $("#mgrType").val();
			judgeMgrName(name);
			var startTime=$("#startTime").val();
	        var endTime=$("#endTime").val();
	        
	        var everyDayStartTime=$("#everyDayStartTime").val();
	        var everyDayEndTime=$("#everyDayEndTime").val();
	        var realTime=$("input[name='realTime']:checked").val();
	        var isLocal=$("input[name='isLocal']:checked").val();
	        var localIsCz=$("input[name='localIsCz']:checked").val();
	        var nonLocalIsCz=$("input[name='nonLocalIsCz']:checked").val();
	        
	        var isThreshold = 0;
            $("input:checkbox[name='isThreshold']:checked").each(function () {
                isThreshold += parseInt($(this).val());
            });
            var threshold = $("#threshold").val();
            var cycleThreshold=0;
            var cycle;
            if(isThreshold==2||isThreshold==3){
               	cycle=$("input[name='cycle']:checked").val();
                cycleThreshold=$("#cycleThreshold").val();
            }
            var localDate = 7;
            var isProvince = 0;
            var nonlocalDate= 7;
            if(isLocal==1){
            	isProvince=$("input[name='province']:checked").val();
            	nonlocalDate=$("input[name='nonlocalDate']:checked").val();
            }else if(isLocal==2){
            	isProvince=$("input[name='province']:checked").val();
            	localDate=$("input[name='localDate']:checked").val();
            	nonlocalDate=$("input[name='nonlocalDate']:checked").val();
            }else if(isLocal==0){
             	localDate=$("input[name='localDate']:checked").val();
            }

			var groupId = $("#mgrGroup").val();
            var param = {
                    cityId: cityId,
                    countyId: countyId,
                    name: name,
                    mgrType : mgrType,
                    startTime: startTime,
                    endTime: endTime,   
                    everyDayStartTime: everyDayStartTime,
                    everyDayEndTime: everyDayEndTime,
                    realTime: realTime,
                    isLocal: isLocal,
                    localIsCz: localIsCz,
                    nonLocalIsCz: nonLocalIsCz,
                    isThreshold:isThreshold,
                    threshold:threshold,
                    cycleThreshold:cycleThreshold,
                    cycle:cycle,
                    localDate: localDate,
                    nonlocalDate: nonlocalDate,
                    isProvince: isProvince,
                    reset:"0",
                    flag: "insert",
					sendType: "1",
					groupId: groupId
                };
            var index;
            var url='/template2/configure';
            layer.confirm('确认模板信息无误吗？是否需要再次查看', {
				btn : [ '不需要', '需要' ] //按钮
			}, function() {
					$.ajax({
	            		type: 'post',
	                    data: param,
	                    url: url,
	                    async: false,
	                    beforeSend: function () {
	                    	if (isNull(cityId)) {
					          layer.msg("地市选项不能为空");
					          return false;
					        }
					        if(flagCity==2){
				              layer.msg("地市已欠费，无法添加项目");
				              return false;
				            }
					        if (isNull(name)) {
					          layer.msg("项目名称不能为空");
					          return false;
					        }
					        
					        if (isNull(mgrType)) {
						          layer.msg("项目类型不能为空");
						          return false;
						        }
						        
					        if (isNull(startTime)) {
					          layer.msg("发送开始时间不能为空");
					          return false;
					        }
					        if (isNull(everyDayStartTime)) {
					          layer.msg("每日发送开始时间不能为空");
					          return false;
					        }
					        if (isNull(everyDayEndTime)) {
					          layer.msg("每日发送结束时间不能为空");
					          return false;
					        }
					        if (isNull(realTime)) {
					          layer.msg("发送实时性不能为空");
					          return false;
					        }
					        if (isNull(isLocal)) {
					          layer.msg("号码发送范围不能为空");
					          return false;
					        }
					        if (""!=endTime && null!=endTime && startTime>=endTime) {
				              layer.msg("发送结束时间不能小于等于开始时间");
				              return false;
				            }
				            if (everyDayStartTime>=everyDayEndTime) {
				              layer.msg("每日发送结束时间不能小于等于每日开始时间");
				              return false;
				            }
				            if(flagMgr>0){
				              layer.msg("项目名重复，请修改");
				              return false;
				            }
				            if(name.length>20){
				              layer.msg("项目名过长，请修改");
				              return false;
				            }
				            if (!checkRate($("#threshold").val())) {
			                    layer.msg("阀值必须为数字，若无需设置阀值将发送条数恢复成0即可（注意不要勾选阀值的选项）");
			                    return false;
			                }
			                if (!checkRate($("#cycleThreshold").val())) {
			                    layer.msg("阀值必须为数字，若无需设置阀值将发送条数恢复成0即可（注意不要勾选阀值的选项）");
			                    return false;
			                }
                			if (isThreshold < 2 && $("#cycleThreshold").val() > 0) {
			                    layer.msg('短信周期发送量大于0，但并未勾选\'周期短信发送量\',按周期设置阀值不会生效,请修改');
			                    return false;
			                } else if (isThreshold != 1 && isThreshold != 3 && $("#threshold").val() > 0) {
			                    layer.msg('短信发送总条数大于0，但并未勾选\'短信发送总量\',总量阀值设置不会生效,请修改');
			                    return false;
			                } 
				           index = layer.load(1, {shade: [0.1,'#fff'] });
	                    },
	                    success: function (obj) {
	                    	layer.close(index);
	                    	if(obj.code==0){
	                    		layer.confirm('添加成功，点击确定配置短信内容', {
							        btn: ['确定'] //按钮
							    }, function (index) {
							    	mgrId = obj.data;
							        $("#second").css("display","");
	            				    step = 2;
	            				    $("#cityId").val(cityId);
	            				    $("#cityId").attr("disabled", true);
	            				    var data2 = selectCountyId(cityId);
		                			appendCounty(data2); 
	            				    $("#countyId").val(countyId);
	            				    $("#countyId").attr("disabled", true);
	            				    var data1 = selectMgrInfo(countyId);
	            				    appendMgr(data1);
	            				    $("#name").attr("disabled", true);
	            				    layer.close(index);
							    });
	                    	}else{
	                    		layer.confirm(obj.msg, {
							        btn: ['确定'] //按钮
							    }, function () {
							        location.href="smsTemplateManage2.html";
							    });
	                    	}
	                    },
	                    error: function(){
	                    	layer.close(index);
	                    	layer.msg('系统异常，请联系管理员处理!');
	                    }
	            });
			});
		}
		
		function submitSecond(){
			var cityId=$("#cityId").val();
			sessionCityId = cityId;
			var mgrType= $("#mgrType").val();
			var startTime=$("#startTime").val();
	        var endTime=$("#endTime").val();
	        
	        var everyDayStartTime=$("#everyDayStartTime").val();
	        var everyDayEndTime=$("#everyDayEndTime").val();
	        var realTime=$("input[name='realTime']:checked").val();
	        var isLocal=$("input[name='isLocal']:checked").val();
	        var localIsCz=$("input[name='localIsCz']:checked").val();
	        var nonLocalIsCz=$("input[name='nonLocalIsCz']:checked").val();
	        var isThreshold = 0;
            $("input:checkbox[name='isThreshold']:checked").each(function () {
                isThreshold += parseInt($(this).val());
            });
            var threshold = $("#threshold").val();
            var cycleThreshold=0;
            var cycle;
            if(isThreshold==2||isThreshold==3){
            	cycle=$("input[name='cycle']:checked").val();
                cycleThreshold=$("#cycleThreshold").val();
            }
            var content=$("#content").val();
            var localDate = 7;
            var isProvince = 0;
            var nonlocalDate= 7;
            if(isLocal==1){
            	isProvince=$("input[name='province']:checked").val();
            	nonlocalDate=$("input[name='nonlocalDate']:checked").val();
            }else if(isLocal==2){
            	//isProvince=1;
            	isProvince=$("input[name='province']:checked").val();
            	localDate=$("input[name='localDate']:checked").val();
            	nonlocalDate=$("input[name='nonlocalDate']:checked").val();
            }else if(isLocal==0){
             	localDate=$("input[name='localDate']:checked").val();
            }

			var groupId = $("#mgrGroup").val();
            var param = {
            		cityId: cityId,
            		mgrId: mgrId,
            		mgrType:　mgrType,
                    startTime: startTime,
                    endTime: endTime,   
                    everyDayStartTime: everyDayStartTime,
                    everyDayEndTime: everyDayEndTime,
                    realTime: realTime,
                    isLocal: isLocal,
                    localIsCz: localIsCz,
                    nonLocalIsCz: nonLocalIsCz,
                    isThreshold:isThreshold,
                    threshold:threshold,
                    cycleThreshold:cycleThreshold,
                    cycle:cycle,
                    content:content,
                    localDate: localDate,
                    nonlocalDate: nonlocalDate,
                    isProvince: isProvince,
                    effectTime:startTime,
                    reset:"0",
                    flag: "modify",
					sendType: "1",
					groupId: groupId
                };
            var url='/template2/modify';
            layer.confirm('确认模板信息无误吗？是否需要再次查看', {
				btn : [ '不需要', '需要' ] //按钮
			}, function() {
				var index = layer.load(1, {shade: [0.1,'#fff'] });
				$.ajax({
	            		type: 'post',
	                    data: param,
	                    url: url,
	                    async: false,
	                    beforeSend: function () {
	                    	if (isNull(mgrType)) {
						          layer.msg("项目类型不能为空");
						          return false;
						        }

					        if (isNull(startTime)) {
					          layer.msg("发送开始时间不能为空");
					          return false;
					        }
					        if (isNull(everyDayStartTime)) {
					          layer.msg("每日发送开始时间不能为空");
					          return false;
					        }
					        if (isNull(everyDayEndTime)) {
					          layer.msg("每日发送结束时间不能为空");
					          return false;
					        }
					        if (isNull(realTime)) {
					          layer.msg("发送实时性不能为空");
					          return false;
					        }
					        if (isNull(isLocal)) {
					          layer.msg("号码发送范围不能为空");
					          return false;
					        }
					        if (isNull(content)) {
					          layer.msg("短信内容不能为空");
					          layer.close(index);
					          return false;
					        }
					        if (""!=endTime && null!=endTime && startTime>=endTime) {
				              layer.msg("发送结束时间不能小于等于开始时间");
				              return false;
				            }
				            if (everyDayStartTime>=everyDayEndTime) {
				              layer.msg("每日发送结束时间不能小于等于每日开始时间");
				              return false;
				            }
	                    },
	                    success: function (obj) {
	                    	layer.close(index);
	                    	if(obj.code==0){
	                    		layer.confirm('添加成功，点击确定配置项目基站', {
							        btn: ['确定'] //按钮
							    }, function (index) {
	            				    $("#next").css("display","none");
							        $("#third").css("display","");
						            $("#upload").css("display","");
						            layer.close(index);
							    });
	                    	}else{
	                    		layer.confirm(obj.msg, {
							        btn: ['确定'] //按钮
							    }, function () {
							        location.href="smsTemplateManage2.html";
							    });
	                    	}
	                    },
	                    error: function(){
	                    	layer.close(index);
	                    	layer.msg('系统异常，请联系管理员处理!');
	                    }
	            });
			});
		}

		$('#upload').on('click', function () {
			fileUpload();
		});

		$('#upload3').on('click', function () {
			fileUpload();
		});
		
		function fileUpload(){
			var mgrType =$("#mgrType").val();
			var startTime=$("#startTime").val();
	        var endTime=$("#endTime").val();
	        var everyDayStartTime=$("#everyDayStartTime").val();
	        var everyDayEndTime=$("#everyDayEndTime").val();
	        var realTime=$("input[name='realTime']:checked").val();
	        var isLocal=$("input[name='isLocal']:checked").val();
			var localIsCz=$("input[name='localIsCz']:checked").val();
	        var nonLocalIsCz=$("input[name='nonLocalIsCz']:checked").val();
	        var isThreshold = 0;
            $("input:checkbox[name='isThreshold']:checked").each(function () {
                isThreshold += parseInt($(this).val());
            });
            var threshold = $("#threshold").val();
            var cycleThreshold=0;
            var cycle;
            if(isThreshold==2||isThreshold==3){
               	cycle=$("input[name='cycle']:checked").val();
                cycleThreshold=$("#cycleThreshold").val();
/*                 if(isThreshold==3){
                	if (cycleThreshold>threshold) {
					          layer.msg("周期阀值不能大于总阀值");
					          return false;
					 }               	
                } */
            }
            var content=$("#content").val();
            var localDate = 7;
            var isProvince = 0;
            var nonlocalDate = 7;
            if(isLocal==1){
            	isProvince=$("input[name='province']:checked").val();
            	nonlocalDate=$("input[name='nonlocalDate']:checked").val();
            }else if(isLocal==2){
            	//isProvince=1;
            	isProvince=$("input[name='province']:checked").val();
            	localDate=$("input[name='localDate']:checked").val();
            	nonlocalDate=$("input[name='nonlocalDate']:checked").val();
            }else if(isLocal==0){
             	localDate=$("input[name='localDate']:checked").val();
            }
			var groupId = $("#mgrGroup").val();
            var param = {
            		mgrId: mgrId,
            		mgrType: mgrType,
                    startTime: startTime,
                    endTime: endTime,   
                    everyDayStartTime: everyDayStartTime,
                    everyDayEndTime: everyDayEndTime,
                    realTime: realTime,
                    isLocal: isLocal,
                    localIsCz: localIsCz,
                    nonLocalIsCz: nonLocalIsCz,
                    isThreshold:isThreshold,
                    threshold:threshold,
                    cycleThreshold:cycleThreshold,
                    cycle:cycle,
                    newContent:content,
                    localDate: localDate,
                    nonlocalDate: nonlocalDate,
                    isProvince: isProvince,
                    effectTime:startTime,
                    reset:"0",
                    flag: "modify",
					sendType: "1",
					groupId: groupId
                };
            var url='/template2/modify';
            layer.confirm('确认模板信息无误吗？是否需要再次查看', {
				btn : [ '不需要', '需要' ] //按钮
			}, function() {
				var index = layer.load(1, {shade: [0.1,'#fff'] });
				$.ajax({
	            		type: 'post',
	                    data: param,
	                    url: url,
	                    async: false,
	                    beforeSend: function () {
	                    	if (isNull(mgrType)) {
						          layer.msg("项目类型不能为空");
						          return false;
						        }
	                    	
					        if (isNull(startTime)) {
					          layer.msg("发送开始时间不能为空");
					          return false;
					        }
					        if (isNull(everyDayStartTime)) {
					          layer.msg("每日发送开始时间不能为空");
					          return false;
					        }
					        if (isNull(everyDayEndTime)) {
					          layer.msg("每日发送结束时间不能为空");
					          return false;
					        }
					        if (isNull(realTime)) {
					          layer.msg("发送实时性不能为空");
					          return false;
					        }
					        if (isNull(isLocal)) {
					          layer.msg("号码发送范围不能为空");
					          return false;
					        }
					        if (isNull(content)) {
					          layer.msg("短信内容不能为空");
					          layer.close(index);
					          return false;
					        }
					        if (""!=endTime && null!=endTime && startTime>=endTime) {
				              layer.msg("发送结束时间不能小于等于开始时间");
				              return false;
				            }
				            if (everyDayStartTime>=everyDayEndTime) {
				              layer.msg("每日发送结束时间不能小于等于每日开始时间");
				              return false;
				            }
	                    },
	                    success: function (obj) {
	                    	if(obj.code==0 && ''!=copyMgrId && null != copyMgrId){
	                    		var url = '/template2/copyStation';
	                    		var params = {
	                    			copyMgrId:copyMgrId,
	                    			mgrId:mgrId
	                    		}
	                    		$.ajax({
	                    			type: 'post',
				                    data: params,
				                    url: url,
				                    async: false,
				                    success: function(obj){
				                    	layer.close(index);
				                    	if(obj.data>0){
				                    		layer.confirm('修改成功，并复制'+obj.data+'个基站', {
							                    btn: ['确定'] //按钮
							                }, function () {
							                    location.href="smsTemplateManage2.html";
							                });
				                    	}else{
				                    		layer.confirm('复制项目失败，如需复制项目，请点击确定留在此页面', {
							                    btn: ['确定','退出'] //按钮
							                }, function () {
							                    layer.close(layer.index);
							                }, function () {
							                    location.href="smsTemplateManage2.html";
							                });
				                    	}
				                    },error: function(){
				                    	layer.close(index);
	                    				layer.msg('系统异常，请联系管理员处理!');
				                    }
	                    		});
	                    	}/* else if (obj.code==0 && ""!=importStationType && null!=importStationType){
	                    	
	                    	} */else{
	                    		layer.close(index);
	                    		layer.confirm(obj.msg, {
							        btn: ['确定'] //按钮
							    }, function () {
							        location.href="smsTemplateManage2.html";
							    });
	                    	}
	                    },
	                    error: function(){
	                    	layer.close(index);
	                    	layer.msg('系统异常，请联系管理员处理!');
	                    }
	            });  
			});
			
		}
		
		$(document).ready(function () {
			$("#upload").css("display","none");
			$("#upload2").css("display","none");
			$("#upload3").css("display","none");
			$("#second").css("display","none");
			$("#third").css("display","none");
			$(".import").css("display","none");
			//$("h4").css("display","none");
			$("#local").show();
			//加载项目类型
			var data=selectMgrType();
			appendMgrType(data);
			
			$.ajax({
                    type: 'post',
                    async: false,
                    url: '/util/findUser',
                    success: function (json) {
                        user=json;
						var data = selectMgrGroupList(json.cityId,json.countyId);
						appendMgrGroup(data);
                        if (json.duty == 1) {
                        	dutyFlag = 1;
                            $("#cityId").val(json.cityId);
                            $("#cityId").attr("disabled", true);
                            $("#cityId_third").val(json.cityId);
                            $("#cityId_third").attr("disabled", true);
                            var data2 = selectCountyId(json.cityId);
                			appendCounty(data2); 
                			appendCountyThird(data2);
                			var data1 = selectMgrInfo(json.cityId);
                			appendMgrThird(data1);
                            form.render();
                        } else if (json.duty == 2) {
                        	dutyFlag=2;
                        	everyDayStartTimeFlag = '08:00:00';
                        	everyDayEndTimeFlag = '20:00:00';
                            $("#cityId").val(json.cityId);
                            $("#cityId").attr("disabled", true);
                            $("#cityId_third").val(json.cityId);
                            $("#cityId_third").attr("disabled", true);
                            var data2 = selectCountyId(json.cityId);
                			appendCounty(data2); 
                			appendCountyThird(data2);
                            $("#countyId").val(json.countyId);
                            $("#countyId").attr("disabled", true);
                            $("#countyId_third").val(json.countyId);
                            $("#countyId_third").attr("disabled", true);
                            var data1 = selectMgrInfo(json.countyId);
                			appendMgrThird(data1);
                            form.render();
                        }else if (json.duty == 3) {
                        	dutyFlag=3;
                        	everyDayStartTimeFlag = '08:00:00';
                        	everyDayEndTimeFlag = '20:00:00';
                        	$("#add").css("visibility","hidden");
                            $("#cityId").val(json.cityId);
                            $("#cityId").attr("disabled", true);
                            $("#cityId_third").val(json.cityId);
                            $("#cityId_third").attr("disabled", true);
                            var data2 = selectCountyId(json.cityId);
                			appendCounty(data2); 
                			appendCountyThird(data2);
                            $("#countyId").val(json.countyId);
                            $("#countyId").attr("disabled", true);
                            $("#countyId_third").val(json.countyId);
                            $("#countyId_third").attr("disabled", true);
                            var data1 = selectMgrInfo(json.countyId);
                			appendMgrThird(data1);
                            appendMgr(json.list);
                            form.render();
                        }

					                           }, error: function () {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
                $(".importType").click(function(){
                	var importType = $("input[name='importType']:checked").val();
                	if(importType==1){
                		$(".import").css("display","");
	                	$(".copy").css("display","none");
	                	$("#upload2").css("display","");
	                	$("#upload").css("display","none");
						$("#upload3").css("display","none");
                	}else if(importType==2){
	                	$(".import").css("display","none");
	                	$(".copy").css("display","");
	                	$("#upload").css("display","");
	                	$("#upload2").css("display","none");
						$("#upload3").css("display","none");
                	}else if(importType==3) {
						$(".import").css("display","none");
						$(".copy").css("display","none");
						$("#upload").css("display","none");
						$("#upload2").css("display","none");
						$("#upload3").css("display","");
						//$("#uploadFile").css("display","");
						sessionStorage.setItem("sessionMgrId",mgrId);
						sessionStorage.setItem("sessionCityId",sessionCityId);
						var url = 'chooseSendRange.html?mgrId='+mgrId;
						layer.open({
							title: '发送范围选择',
							type: 2,
							content: url,
							area: ['1000px', '550px'],
							scrollbar: true
						});
						// layer.open({
						// 	type: 2,
						// 	title: '发送范围选择',
						// 	shadeClose: true,
						// 	offset: 'auto',
						// 	shade: 0.8,
						// 	area: ['60%', '50%'],
						// 	content: 'chooseSendRange.html?mgrId='+mgrId //iframe的url
						// });
					}
                });
		});
				$("#mgrName1").autocomplete({
       source : function( request, response ) {
        var key = $("#mgrName1").val();
        var cityId=$("#cityId").val();
        var countyId=$("#countyId").val();
        var url = '/util/selectMgrNameLike';
        var param = {
            cityId : cityId,
            countyId : countyId,
         key : key
        };
                 $.ajax({
         type : 'post',
         async : false,
         url : url,
         data : param,
         success : function(json) {
          var data = json.data;
          source = [];
          for (var i = 0; i < data.length; i++) {
           source[i] = data[i].name;
          }
          console.log(source);
          response( source );
         },
         error : function() {
          layer.msg('系统异常，请联系管理员处理!');
         }
        }
        );
            },
       messages : { //message设置不出现匹配关键字的结果
        noResults : '',
        results : function() {
        }
       }
      });
	});
</script>
</head>
<body>
	<!--nav-->
	<div class="layui-html-limit">
		<!--container-->
		<div class="layui-content-body">
			<div class="scroll-box">
				<div class="breadcrumb-box">
					<span class="layui-breadcrumb" lay-separator="|"> <a
						href="javascript:returnIndex2()">首页&nbsp;</a> <a href="">
							&nbsp;短信模板管理&nbsp; </a> <a href="smsTemplateManage2.html">
							&nbsp;短信项目模板配置管理</a> <a href=""> &nbsp;短信项目模板配置&nbsp; </a>
					</span>
				</div>
				<div class="content-box">
					<div class="layui-form layui-form-pane">
						<div class="layui-form-item" id="first">
							<div class="layui-inline">
								<label class="layui-btn layui-btn-lg layui-btn-normal" style="cursor:auto;">第一步：项目基本信息配置</label>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">地市</label>
									<div class="layui-input-block" style="width:150px">
										<select name="cityId" lay-filter="cityId" id="cityId">
											<option value="">请选择</option>
											<option value="11">苏州</option>
											<option value="12">淮安</option>
											<option value="13">宿迁</option>
											<option value="14">南京</option>
											<option value="15">连云港</option>
											<option value="16">徐州</option>
											<option value="17">常州</option>
											<option value="18">镇江</option>
											<option value="19">无锡</option>
											<option value="20">南通</option>
											<option value="21">泰州</option>
											<option value="22">盐城</option>
											<option value="23">扬州</option>
											<!-- <option value="25">省级</option> -->
										</select>
									</div>
								</div>
								<div class="layui-inline"><span style="color:red;">*</span></div>
								<div class="layui-inline countyId">
		                            <label class="layui-form-label">区县</label>
		                            <div class="layui-input-block" style="width:150px">
		                                <select name="countyId" lay-filter="countyId" id="countyId">
		                                    <option value="">全部</option>
		                                </select>
		                            </div>
		                        </div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">项目名称</label>
									<div class="layui-input-block">
										<input type="text" name="name" id="name" required
											lay-verify="required" placeholder="请输入项目名称" autocomplete="off"
											class="layui-input">
									</div>
								</div>
								<div class="layui-inline"><span style="color:red;">*(项目名称不可重复，且名称长度不超过20个字)</span></div>
							</div>
							
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">项目类型</label>
									<div class="layui-input-block" style="width:184px">
										<select name="mgrType" lay-filter="mgrType" id="mgrType">
										</select>
									</div>
								</div>
								<div class="layui-inline"><span style="color:red;">*</span></div>
							</div>

							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">项目分组</label>
									<div class="layui-input-block" style="width:184px">
										<select name="mgrGroup" lay-filter="mgrGroup" id="mgrGroup">
										</select>
									</div>
								</div>
								<div class="layui-inline"><span style="color:red;">*</span></div>
							</div>
							
							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label" style="width: auto">发送起止时间</label>
									<div class="layui-input-inline">
										<input type="text" name="date" id="startTime"
											autocomplete="off" class="layui-input" placeholder="请选择"
											lay-verify="required">
									</div>
									<div class="layui-form-mid">-</div>
									<div class="layui-input-inline">
										<input type="text" name="date" id="endTime" autocomplete="off"
											class="layui-input" placeholder="请选择">
									</div>
									<div class="layui-inline"><span style="color:red;">*(结束时间默认为23:59:59,并且可以为空,代表永久有效)</span></div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label" style="width:auto">每日发送时间段</label>
									<div class="layui-input-inline">
										<input type="text" name="date" id="everyDayStartTime"
											autocomplete="off" class="layui-input" placeholder="请选择">
									</div>
									<div class="layui-form-mid">-</div>
									<div class="layui-input-inline">
										<input type="text" name="date" id="everyDayEndTime"
											autocomplete="off" class="layui-input" placeholder="请选择">
									</div>
									<div class="layui-inline"><span style="color:red;">*</span></div>
									<!-- <div class="layui-inline">(若想在发送起止时间内连续发送，请将每日发送时间段置为00:00:00至23:59:59)</div> -->
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block" pane="">
									<label class="layui-form-label">发送实时性</label>
									<div class="layui-input-block">
										<input type="radio" name="realTime" value="0" title="立即发送">
										<input type="radio" name="realTime" value="5" title="延迟5分钟发送">
										<input type="radio" name="realTime" value="10" title="延迟10分钟发送">
										<input type="radio" name="realTime" value="20" title="延迟20分钟发送"
											checked="">
											<span style="color:red;">*</span>
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">号码发送范围</label>
									<div class="layui-input-block">
										<input type="radio" name="isLocal" value="0" title="本地"lay-filter="localDate1" checked="checked"> 
										<input type="radio" name="isLocal" value="1" title="外地" lay-filter="localDate1">
										<input type="radio" name="isLocal" value="2" title="本地+外地" lay-filter="localDate1">
											<span style="color:red;">*</span>
									</div>
								</div>
							</div>
							
					<div class="layui-form-item" id="localIsCz" style="display: none">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">本地发送是否屏蔽常驻人口</label>
									<div class="layui-input-block">
										<input type="radio" name="localIsCz" value="0" title="是"lay-filter="localIsCz" > 
										<input type="radio" name="localIsCz" value="1" title="否" lay-filter="localIsCz" checked="checked">
											<span style="color:red;">*</span>
									</div>
								</div>
							</div>
							
							<div class="layui-form-item" id="nonLocalIsCz" style="display: none">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">常驻人口发送范围</label>
									<div class="layui-input-block">
										<input type="radio" name="nonLocalIsCz" value="2" title="常驻"lay-filter="nonLocalIsCz" > 
										<input type="radio" name="nonLocalIsCz" value="0" title="非常驻" lay-filter="nonLocalIsCz" checked="checked">
										<input type="radio" name="nonLocalIsCz" value="1" title="全部" lay-filter="nonLocalIsCz">
											<span style="color:red;">*</span>
									</div>
								</div>
							</div> 
							
							<div class="layui-form-item hiden" id="local"
								style="display: none">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">本地号码保存时间</label>
									<div class="layui-input-block">
										<input type="radio" name="localDate"value="1" title="1天" lay-filter="localDate">
										<input type="radio" name="localDate"value="3" title="3天" lay-filter="localDate">
										<input type="radio" name="localDate"value="5" title="5天" lay-filter="localDate">
										<input type="radio" name="localDate" value="7" title="7天" lay-filter="localDate" checked=""> 
										<input type="radio" name="localDate"value="15" title="15天" lay-filter="localDate"> 
										<input type="radio"name="localDate" value="30" title="30天" lay-filter="localDate"> 
										<input type="radio" name="localDate" value="90" title="90天" lay-filter="localDate">
										<input type="radio" name="localDate" value="180" title="180天" lay-filter="localDate">
										<span style="color:red;">*</span>
									</div>
								</div>
							</div>
							<div class="layui-form-item hiden" id="nonlocal"
								style="display: none">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">外地号码保存时间</label>
									<div class="layui-input-block">
										<input type="radio" name="nonlocalDate"value="1" title="1天" lay-filter="nonlocalDate">
										<input type="radio" name="nonlocalDate"value="3" title="3天" lay-filter="nonlocalDate">
										<input type="radio" name="nonlocalDate"value="5" title="5天" lay-filter="nonlocalDate">
										<input type="radio" name="nonlocalDate" value="7" title="7天" lay-filter="nonlocalDate" checked=""> 
										<input type="radio" name="nonlocalDate" value="15" title="15天" lay-filter="nonlocalDate" > 
										<span style="color:red;">*</span>
									</div>
								</div>
							</div>
							<div class="layui-form-item hiden" id="province"
								style="display: none">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">发送范围选择</label>
									<div class="layui-input-block">
										<input type="radio" name="province" value="0" title="省内" checked="checked"> 
										<input type="radio" name="province" value="1" title="全部"> 
										<span style="color:red;">*</span>
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label" style="width: auto">短信发送量阀值设置</label>
								<div class="layui-inline">
									<div class="layui-form-item">
										<div class="layui-inline">
											<input type="checkbox" name="isThreshold" title="短信发送总量"
												value="1">
										</div>
										<div class="layui-inline"><span style="color:red;">*(不设置阀值，短信数量无上限)</span></div>
									</div>
									<div class="layui-form-item">
										<div class="layui-inline" pane="">
											<label class="layui-form-label" style="width: auto">短信发送总条数:</label>
											<div class="layui-input-inline" style="width: auto">
												<input type="text" id="threshold" placeholder="请输入"
													autocomplete="off" class="layui-input" value="0">
											</div>
										</div>
										<div class="layui-inline">条</div>
									</div>
									<div class="layui-form-item">
										<input type="checkbox" name="isThreshold" title="周期短信发送量"
											value="2">
									</div>
									<div class="layui-inline" pane="">
										<input type="radio" name="cycle" value="1" title="按年" checked>
										<input type="radio" name="cycle" value="2" title="按月">
										<input type="radio" name="cycle" value="3" title="按周">
										<input type="radio" name="cycle" value="4" title="按日">
	
	
									</div>
									<div class="layui-form-item">
										<h4 class="tips-h4">
											<i class="iconfont icon-xinxi"></i>
											周发送量不是当天的起，是该周周一开始计算，月发送量就是从当月一号开始算。
										</h4>
									</div>
									<div class="layui-form-item">
										<div class="layui-form-item">
											<div class="layui-inline" pane="">
												<label class="layui-form-label">短信发送量:</label>
												<div class="layui-input-inline" style="width: 100px;">
													<input type="text" placeholder="请输入" id="cycleThreshold"
														autocomplete="off" class="layui-input" value="0">
												</div>
											</div>
											<div class="layui-inline">条</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item layui-form-text" id="second">
							<div class="layui-inline">
								<label class="layui-btn layui-btn-lg layui-btn-normal" style="cursor:auto;">第二步：项目发送内容配置</label>
							</div>
							<br> <label class="layui-form-label">短信内容</label>
							<div class="layui-input-block">
								<textarea class="layui-textarea" id="content"
									lay-verify="required"></textarea>
							</div>
							<div class="layui-form-item">
						<span >
						      <button  type="button" class="layui-btn layui-btn-normal"   id="qryContentCount">查看短信条数</button>
						</span>
							<h4 class="tips-h4"  id="contentCount" style="display:none;color:#F00">
								短信长度为&nbsp;&nbsp;<span id="contentLength">0</span>&nbsp;&nbsp;,&nbsp;将发送&nbsp;&nbsp;<span id="contentNum">0</span>&nbsp;&nbsp;条短信<span id="thresholdNum"></span>
								<span id="thresholdMsg"></span>
							</h4>
						</div>
						</div>
						<div class="layui-form-item" id="third">
							<div class="layui-inline">
								<label class="layui-btn layui-btn-lg layui-btn-normal" style="cursor:auto;">第三步：项目基站信息导入</label>
							</div>
							<div class="layui-form-item importType">
					                    	<label class="layui-form-label" style="width:120px">导入方法</label>
					                        <div class="layui-input-block">
					                            <input class="radioItem" lay-filter="gis" type="radio" name="importType" title="导入基站" onclick="ChooseRadio(this)" value="1">
												<input class="radioItem" lay-filter="gis" type="radio" name="importType" title="复制其他项目基站" onclick="ChooseRadio(this)" value="2" checked="checked">
												<input class="radioItem" lay-filter="gis" type="radio" name="importType" title="范围选择" onclick="ChooseRadio(this)" value="3">
					                        </div>
					        </div>
					        <div class="layui-form-item copy">
								<div class="layui-inline ">
									<label class="layui-form-label">地市</label>
									<div class="layui-input-block" style="width:150px">
										<select name="cityId_third" lay-filter="cityId_third" id="cityId_third">
											<option value="">请选择</option>
											<option value="11">苏州</option>
											<option value="12">淮安</option>
											<option value="13">宿迁</option>
											<option value="14">南京</option>
											<option value="15">连云港</option>
											<option value="16">徐州</option>
											<option value="17">常州</option>
											<option value="18">镇江</option>
											<option value="19">无锡</option>
											<option value="20">南通</option>
											<option value="21">泰州</option>
											<option value="22">盐城</option>
											<option value="23">扬州</option>
											<option value="25">省级</option>
										</select>
									</div>
								</div>
								<div class="layui-inline countyId">
		                            <label class="layui-form-label">区县</label>
		                            <div class="layui-input-block" style="width:150px">
		                                <select name="countyId_third" lay-filter="countyId_third" id="countyId_third">
		                                    <option value="">全部</option>
		                                </select>
		                            </div>
		                        </div>
		                        <div class="layui-inline mgrId">
		                            <label class="layui-form-label">项目名称</label>
		                            <div class="layui-input-block" style="width:150px">
		                                <select name="mgrId_third" lay-filter="mgrId_third" id="mgrId_third">
		                                    <option value="">请选择</option>
		                                </select>
		                            </div>
		                        </div>
		                                   	<div class="layui-inline">
                            <label class="layui-form-label">项目简称</label>
                            <div class="layui-input-block" style="width:150px">
                                <input type="text"  name="mgrName1" id="mgrName1" lay-verify="required" placeholder="请输入"
                                            autocomplete="off" class="layui-input" />
                            </div>
                        </div>
		                        <div class="layui-inline">
		                            <div class="layui-block">
				                            <button class="layui-btn layui-btn-normal" id="copy">复制</button>
				                            <label id="copyMgrId" style="visibility:hidden;">123</label>
				                	</div>
		                        </div>
							</div>
							<div class="layui-form-item import">
								<br>
								<div class="layui-inline">
									<button type="button" class="layui-btn" id="import">
										<i class="layui-icon"></i>区域基站导入
									</button>
								</div>
								<br class="layui-form-item"> <span><a
									href="/smsBaseStation/apidownload"><u>基站导入帮助手册</u></a></span></br> <span><a
									href="/smsBaseStation/modeldownload"><u>基站导入模板下载</u></a></span>
								<div class="layui-form-item">
										<h4 class="tips-h4">
											<i class="iconfont icon-xinxi"></i>
											请先选择导入的文件再点击提交
										</h4>
								</div>
							</div>
						</div>
						<div class="layui-block">
	                            <button class="layui-btn layui-btn-normal" id="next">下一步</button>
	                	</div>
						<div class="layui-form-item">
							<button class="layui-btn" id="upload2">提交</button>
						</div>
						<div class="layui-form-item">
							<button class="layui-btn" id="upload">提交</button>
						</div>
						<div class="layui-form-item" style="display:none;">
							<button class="layui-btn" id="uploadFile">提交</button>
						</div>
						<div class="layui-form-item">
							<button class="layui-btn" id="upload3">提交</button>
						</div>
					</div>
					<h4 class="tips-h4">
						<i class="iconfont icon-xinxi"></i>
						地市短信项目管理员设置或者修改模板属性提交后短信通知省公司管理员审核，审核通过后设置或者修改属性才能生效
					</h4>
				</div>
			</div>
		</div>
	</div>
</body>
</html>